package com.guigu.www.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.guigu.www.common.PageVo;
import com.guigu.www.mapper.DeptMapper;
import com.guigu.www.pojo.Employee;
import com.guigu.www.mapper.EmployeeMapper;
import com.guigu.www.service.EmployeeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tj
 * @since 2021-03-17
 */
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {
    @Autowired
    EmployeeMapper employeeMapper;
    @Autowired
    DeptMapper deptMapper;

    @Override
//    ,Employee employee
    public PageVo<Employee> findList(Map<String,String> map) {
        Integer pageNum=Integer.valueOf(map.get("pageNum")+"");//当前页
        Integer pageSize=Integer.valueOf(map.get("pageSize")+"");//每页显示的条数
//        String ename=map.get("ename");
//        String star=map.get("star");
//        String stop=map.get("stop");
//        String deptno=map.get("deptno");
//        employee.setEname(ename);
//        employee.setDeptno(Integer.parseInt(deptno));
//        employee.setHiredate(star);
//        employee.setHiredate(stop);
//        System.out.println(ename);
//        System.out.println(star);
//        System.out.println(stop);
//        System.out.println(deptno);
        Page<Employee> page=new Page<>(pageNum,pageSize);
//        Wrapper<Employee> entity = new EntityWrapper<>(employee);
//        ,employee
        List<Employee> list = employeeMapper.findList(page);
        PageVo<Employee> objectPage = new PageVo<>();
        objectPage.setTotal(page.getTotal());
        objectPage.setRows(list);
        return objectPage;
    }

//    @Override
//    public PageVo<Employee> findList(Map<String, String> map, Employee employee) {
//                Integer pageNum=Integer.valueOf(map.get("pageNum")+"");//当前页
//        Integer pageSize=Integer.valueOf(map.get("pageSize")+"");//每页显示的条数
//        String ename=map.get("ename");
//        String star=map.get("star");
//        String stop=map.get("stop");
//        String deptno=map.get("deptno");
//        employee.setEname(ename);
//        employee.setDeptno(Integer.parseInt(deptno));
//        employee.setHiredate(star);
//        employee.setHiredate(stop);
//        System.out.println(ename);
//        System.out.println(star);
//        System.out.println(stop);
//        System.out.println(deptno);
//        Page<Employee> page=new Page<>(pageNum,pageSize);
//        List<Employee> list = employeeMapper.findList(page,employee);
//        PageVo<Employee> objectPage = new PageVo<>();
//        objectPage.setTotal(page.getTotal());
//        objectPage.setRows(list);
//        return objectPage;
//    }

    @Override
    public Employee queryById(int empno) {
        return employeeMapper.queryById(empno);
    }

    @Override
    public int addEmp(Employee employee) {
        return employeeMapper.addEmp(employee);
    }

    @Override
    public int updEmp(Employee employee) {
        return employeeMapper.updEmp(employee);
    }

    @Override
    public int delEmp(int empno) {
        return employeeMapper.delEmp(empno);
    }
}
